<script>

/**
 * Orders Component
 */
export default {
  data() {
    return {
      ordersData: [
        {
          name: "隔膜业务量利齐升，业绩符合预期",
          code: "300568",
          abbreviation: "星源材质",
          mechanism: "东吴证券",
          industry: "电池",
          date: "2022/1/29",
        },{
          name: "贝达药业：业绩稳健增长，新产品新适应症打开增长空间",
          code: "300558",
          abbreviation: "贝达药业",
          mechanism: "首创证券",
          industry: "化学制药",
          date: "2022/1/29",
        },{
          name: "天齐锂业深度报告：扩产乘风资源价格重估，锂资源巨头王者归来",
          code: "2466",
          abbreviation: "天齐锂业",
          mechanism: "浙商证券",
          industry: "能源金属",
          date: "2022/1/29",
        },{
          name: "业绩预告点评：营收利润高速增长，车载模组加速布局",
          code: "603236",
          abbreviation: "移远通信",
          mechanism: "民生证券",
          industry: "通信设备",
          date: "2022/1/29",
        },{
          name: "深信服2021年业绩预告点评：转型短期阵痛，不改长期XaaS高景气",
          code: "300454",
          abbreviation: "深信服",
          mechanism: "民生证券",
          industry: "软件开发",
          date: "2022/1/29",
        }
      ],
      totalRows: 1,
      currentPage: 1,
      perPage: 10,
      fields: [
        { key: "name", label: "报告名称" },
        { key: "code", label: "股票代码" },
        { key: "abbreviation", label: "股票简称" },
        { key: "mechanism", label: "研究机构" },
        { key: "industry", label: "行业" },
        { key: "date", label: "日期" },
        { key: "viewDetail", label: "查看" },
      ],
      pickerOptions: {
        shortcuts: [
          {
            text: '最近一周',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit('pick', [start, end]);
            }
          }, {
            text: '最近一个月',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
              picker.$emit('pick', [start, end]);
            }
          }, {
            text: '最近三个月',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
              picker.$emit('pick', [start, end]);
            }
          }
        ]
      },
      dateRange: '',
    };
  },
  watch: {
    "currentPage":{
      handler() {
        console.log("触发分页",this.currentPage);
      },
    }
  },
  mounted() {
    // Set the initial number of items
    this.totalRows = this.ordersData.length;
  },
  methods: {
    /**
     * Search the table data with search input
     */
    onFiltered(filteredItems) {
      // Trigger pagination to update the number of buttons/pages due to filtering
      this.totalRows = filteredItems.length;
      this.currentPage = 1;
    },
  }
};
</script>

<template>
  <div>
    <!-- 搜索 -->
    <div class="search-box">
      <div class="position-relative search">
        <input type="text" class="form-control" placeholder="输入股票代码或股票简称或研报标题中包含内容" />
        <i class="mdi mdi-magnify search-icon"></i>
      </div>
    </div>
    <div class="allNum">
      <div class="searchNum">为您检索到<span>5,000+</span>条股票信息</div>
      <div style="display:flex;">
        <div style="margin-right: 20px;">
          <select class="form-control">
            <option>选择行业</option>
            <option>电池</option>
            <option>化学制药</option>
            <option>能源金属</option>
            <option>通信设备</option>
            <option>软件开发</option>
          </select>
        </div>
        <div style="margin-right: 20px;">
          <el-date-picker
            v-model="dateRange"
            type="datetimerange"
            :picker-options="pickerOptions"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            >
          </el-date-picker>
        </div>
        <b-dropdown dropup variant="secondary" class="butn">
          <template slot="button-content">
            <i class="ri-add-line align-middle" style="font-size: 1rem;"></i>
            <span style="margin:0 20px 0 6px;">更多操作</span>
            <i class="mdi mdi-chevron-up"></i>
          </template>
          <b-dropdown-item-button>创建接口</b-dropdown-item-button>
          <b-dropdown-item-button>查看日志</b-dropdown-item-button>
          <b-dropdown-item-button>标准模式</b-dropdown-item-button>
          <b-dropdown-item-button>SQL模式</b-dropdown-item-button>
          <b-dropdown-item-button>数据字段</b-dropdown-item-button>
        </b-dropdown>
      </div>
    </div>
    <div class="table-responsive">
      <b-table
        class="table-centered"
        :items="ordersData"
        :fields="fields"
        responsive="sm"
        :per-page="perPage"
        :current-page="1"
        thead-class="thead-light"
        @filtered="onFiltered"
      >
        <template v-slot:cell(viewDetail)>
          <div>详情</div>
        </template>
      </b-table>
    </div>
    <div class="row">
      <div class="col">
        <div class="dataTables_paginate paging_simple_numbers float-right">
          <ul class="pagination pagination-rounded mb-0">
            <b-pagination v-model="currentPage" :total-rows="totalRows" :per-page="perPage"></b-pagination>
          </ul>
        </div>
      </div>
    </div>
  </div>
</template>
<style lang="scss" scoped>
.search {
  max-width: 300px;
  margin-top: 20px;
  margin-bottom: 20px;
}
.border-radius{
  border-radius: 0px;
  border-bottom-left-radius: 30px;
  border-top-left-radius: 30px;
}
.right-dropdown{
  ::v-deep .btn{
    font-size: 0;
    border-radius: 0px;
    padding: 0.47rem 0.5rem;
    border-bottom-right-radius: 30px;
    border-top-right-radius: 30px;
    i{
      font-size: 0.9rem;
      vertical-align: middle;
    }
  }
}
.table-centered{
  ::v-deep thead,::v-deep tbody{
    tr{
      th:last-child,td:last-child{
        text-align: right;
      }
    }
  }
  ::v-deep tbody{
    tr{
      td{
        font-size: 13px;
      }
    }
  }
}
.allNum{
  padding-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.searchNum{
  span{
    font-size: 1rem;
    color: #3444c1;
    margin: 0 4px;
    font-weight: 600;
  }
}
.butn{
  ::v-deep .btn{
    background-color: #252b3b;
    border-color: #252b3b;
    border-radius: 30px;
    display: flex;
    align-items: center;
  }
  ::v-deep .btn-secondary.focus {
    box-shadow: 0 0 0 0.15rem rgb(37 40 58 / 50%);
  }
}
</style>

